import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, RelationId, ManyToOne, JoinColumn } from "typeorm";
import { Category } from "../category/category.entity";
import { IsNotEmpty, IsString, Max } from "class-validator";

@Entity('article_comment')
export class ArticleComment {
  /**
   * id
   */
  @PrimaryGeneratedColumn()
  id: number

  @Column({
    length: 40
  })
  @IsNotEmpty({
    message: '缺少参数'
  })
  @IsString({ message: '名字格式错误' })
  @Max(40, { message: '名字过长过长' })
  name: string

  @Column({
    nullable: true
  })
  face?: string

  @Column()
  @IsNotEmpty({ message: '缺少参数' })
  @IsString({ message: '内容格式错误' })
  @Max(255, { message: '评论内容过长' })
  content: string

  @Column({
    length: 40
  })
  @IsNotEmpty({ message: '缺少参数' })
  @IsString({ message: '邮箱格式错误' })
  @Max(40, { message: '邮箱过长' })
  email: string

  @Column({
    length: 40,
    nullable: true,
  })
  website?: string

  @CreateDateColumn()
  createDate: Date = new Date()

  @UpdateDateColumn()
  updateDate: Date = new Date()

  @Column()
  articleId: number
}